<template>
  <el-form
    ref="userForm"
    :model="userInfo"
    label-width="120px"
    style="margin-left: 120px; margin-top: 30px"
  >
    <el-form-item label="姓名:">
      <el-input
        v-model="userInfo.username"
        style="width:300px"
      />
    </el-form-item>
    <el-form-item label="密码:">
      <el-input
        v-model="userInfo.password"
        disabled
        type="password"
        style="width:300px"
      />
    </el-form-item>

    <el-form-item>
      <el-button type="primary" @click="updateInfo">更新</el-button>
    </el-form-item>
  </el-form>
</template>
<script>
import { getUserBasicInfo, updateUserInfo } from '@/api/employees'
export default {
  data() {
    return {
      userInfo: {
        username: '',
        password: ''
      }
    }
  },
  created() {
    this.getInfo()
  },
  methods: {
    // 获取员工基本信息
    async getInfo() {
      const { data } = await getUserBasicInfo(this.$route.params.id)
      console.log(data)
      this.userInfo = data.data
    },
    async updateInfo() {
      const { data } = await updateUserInfo(this.userInfo)
      console.log(data)
      this.$router.back()
    }
  }
}
</script>

